import numpy as np

array = np.random.randint(low=1, high=1000, size=10)

print(array)


def merge_sort(a: list) -> object:
    return sort(0, len(a) - 1, a)


def sort(low: int, high: int, a: list) -> object:
    if low < high:
        middle = low + (high - low) // 2
        sort(low, middle, a)
        sort(middle + 1, high, a)
        merge(low, middle, high, a)


def merge(low: int, middle: int, high: int, a: list) -> object:
    aux = array.copy()
    i = low
    j = middle + 1
    k = low
    while i <= middle and j <= high:
        if aux[i] < aux[j]:
            a[k] = aux[i]
            i += 1
        else:
            a[k] = aux[j]
            j += 1
        k += 1
    if i > middle:
        while j <= high:
            a[k] = aux[j]
            j += 1
            k += 1
    if j > high:
        while i <= middle:
            a[k] = aux[i]
            i += 1
            k += 1


merge_sort(array)

print(array)
